<template>
  <div class="container" @click="isChecked=!isChecked" :style="{background:isChecked ? '#67c23a' : 'ffffff'} ">
    <div :class="{
      'circle-animation-open':isChecked,
      'circle-animation-close':!isChecked,

    }" class="circle"
    ></div> 
  </div>
</template>

<script>
export default {
  data() {
    return {
      isChecked: false,
    }
  },
}
</script>

<style scoped>
.container {
  display: inline-block;
  position: relative;
  width: 50px;
  height: 20px;
  border: 1px solid #eee;
  border-radius: 16px;
  background-color: #eee;
  transition: all 0.2s;
  cursor: pointer;
}
/* ⚪ */
.circle {
  position: absolute;
  top: 0;
  left: 0;
  width: 18px;
  height: 18px;
  border-radius: 15px;
  background-color: #ffffff;
  box-shadow: 0 1px 3px #909399;
}
.circle-animation-open{
  left: 30px;
  animation: circleOpen 0.2s infinite;
  animation-iteration-count: 1;
 
}
.circle-animation-close{
  left: 0px;
  animation: circleOpen 0.2s infinite;
  animation-iteration-count: 1;

}
@keyframes circleOpen{
  0%{
    left:0;
  }
   50%{
    left:50%;
  }
   100%{
    right:0px;
  }
}
  @keyframes circleClose{
  0%{
   right:0px;
  }
   50%{
   right:50%;
  }
   100%{
    left:0px;
  }
}
</style>
